<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <?php include_once MvcReg::$_moduleName . '/views/layout/head.php'; ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
    <style>
        .bootstrap-select.form-control:not([class*="col-"]){
            width: 60%;
        }
    </style>
</head>
<body>
<?php include_once MvcReg::$_moduleName . '/views/layout/woody-prompt.php'; ?>
<?php include_once MvcReg::$_moduleName . '/views/layout/header.php'; ?>
<div id="main">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-2">
                <?php include_once MvcReg::$_moduleName . '/views/layout/left_menu.php'; ?>
            </div>
            <div class="col-md-10">
                <div class="right-content">
                    <h3>
                        <ol class="breadcrumb">
                            <li><a href="?md=manage&cl=riders&at=riderslist"><i class="fa fa-dashboard"></i><?php echo $menu["breadcrumb_current"] ?></a></li>
                        </ol>
                    </h3>
                    <br>
                    <form name="mainform" action="" method="get">
                    <?php echo $hidden_data?>
                    <div class="table-responsive">
                        <div class="panel panel-default">
                            <div class="panel-body form-inline">
                                <div class="form-group">
                                    <label>姓名:</label>
                                    <input type="text" name="_name" value="<?php echo $_name ?>" class="form-control input-sm" placeholder=""/>
                                </div>

                                <div class="form-group">
                                    <label>电话:</label>
                                    <input type="text" name="_phone" value="<?php echo $_phone ?>" class="form-control input-sm" placeholder=""/>
                                </div>

                                <div class="form-group">
                                    <label>状态:</label>
                                    <?php echo Tools::selectOptions("_riders_status", Data::$_riders_status_code_search, '全部', true, $_riders_status, 'class="form-control select"'); ?>
                                </div>

                                <div class="form-group" style="width: 20%;" id="p">
                                    <label>服务城市:</label>
                                    <select class="selectpicker show-tick form-control" id="province" name="_p" data-live-search="true">
                                        <option value="">请选择...</option>
                                        <?php foreach($Areas as $pk => $p){
                                            if($_p == $p['code']){
                                                $selected = 'selected="selected"';
                                            }else{
                                                $selected = '';
                                            }
                                            echo ' <option '.$selected.' value="'.$p['code'].'">'.$p['name'].'</option>';
                                        }?>
                                    </select>
                                </div>

                                <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span>立即查询</button>
                                <button type="button" class="btn btn-primary floatright"><a style="color: white" href="?md=manage&cl=riders&at=ExportExcel&name=<?php echo $_name ?>&phone=<?php echo $_phone ?>&riders_status=<?php echo $_riders_status ?>&_p=<?php echo $_p ?>&_c=<?php echo $_c ?>&_a=<?php echo $_a ?>&type=1">汇出</a></button>
                            </div>
                        </div>
                        <table class="table table-hover">
                            <thead>
                            <tr class="info">
                                <th>序</th>
                                <th>名称</th>
                                <th>性别</th>
                                <th>年龄</th>
                                <th>联系电话</th>
                                <th>状态</th>
                                <th>审核</th>
                                <th>状态</th>
                                <th>功能</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            $n = 0;
                            foreach ($rsp_list as $k => $row) {
                                $n++;
                                $item = $n + ($page - 1) * $number_page;
                                $id = $row["id"];

                                $initiateStatus = Data::$_riders_status_code_search[$row['initiate']];

                              switch ($row['initiate']){
                                    case 1;
                                    $editInitiateStatus = Data::$_riders_status_code_search[2];
                                    break;
                                    case 2;
                                    $editInitiateStatus = Data::$_riders_status_code_search[1];
                                    break;
                              };

                              switch ($row['sex']){
                                    case 1;
                                        $sex = '男';
                                    break;
                                    case 0;
                                        $sex = '女';
                                    break;
                              };
                                ?>
                                <tr data-id="<?php echo $id?>">
                                    <td><?php echo $item ?></td>
                                    <td><?php echo $row['name'] ?></td>
                                    <td><?php echo $sex ?></td>
                                    <td><?php echo $row['age'] ?></td>
                                    <td><?php echo $row['tel'] ?></td>
                                    <td><?php echo $initiateStatus ?></td>
                                    <td><?php echo  '已通过' ?></td>

                                    <td>
                                        <input name="input" value="查看"
                                               onclick="edit('<?php echo $id; ?>', '<?php echo $page; ?>','<?php echo $this_url?>_check')"
                                               type="button" class="btn btn-success btn-sm"/>
                                        <input name="input" value="<?php echo $editInitiateStatus ?>"
                                               onclick="changeStatus('<?php echo $id; ?>', '<?php echo $page; ?>','<?php echo $this_url?>')"
                                               type="button" class="btn btn-success btn-sm"/>
                                        <input name="input" value="%{DEL}%"
                                               onclick="del('<?php echo $id; ?>', '<?php echo $this_url?>')"
                                               type="button" class="btn btn-success btn-sm"/>
                                    </td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                        <div class="page">
                                <div class="pagination pull-left">共<?php echo $total_count ?>笔记录</div>
                                <?php if (!empty($rsp_page_list)) echo $rsp_page_list; ?>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<?php include_once MvcReg::$_moduleName . '/views/layout/footer.php'; ?>
<script>

        $(function () {
            var p = <?php echo $_p;?>;
            var c = <?php echo $_c;?> ;
            var a = <?php echo $_a;?> ;
            if(p && p !==999 || c && c !==999 || a && a !==999){
                $.ajax({
                    url:"?md=manage&cl=riders&at=getCitys",
                    type:"post",
                    dataType:"json",
                    data:{'code':p},
                    success:function (d) {
                        var selected = '';
                        if(d.status == 1){
                            var sl = '  <div class="form-group" style="width: 20%; " id="c"><label>服务市:</label><select class=" show-tick form-control" id="city" name="_c" data-live-search="true"><option value="">请选择...</option>';
                            $(d.data).each(function (k,v) {
                                if(c == v.code){
                                    selected = 'selected="selected"';
                                }else{
                                    selected = '';
                                }
                                sl +='<option '+selected+' value="'+v.code+'">'+v.fullname+'</option>';
                            });
                            sl += '</select></div>';
                            $("#p").after(sl);
                        }


                    $.ajax({
                        url:"?md=manage&cl=riders&at=getAreas",
                        type:"post",
                        dataType:"json",
                        data:{'code':c},
                        success:function (d) {
                            console.log(d);
                            var sl = '  <div class="form-group" style="width: 20%; "  id="a"><label>服务区:</label><select class=" show-tick form-control" name="_a" data-live-search="true"><option value="">请选择...</option>';
                            $(d.data).each(function (k,v) {
                                if(a == v.code){
                                    selected = 'selected="selected"';
                                }else{
                                    selected = '';
                                }
                                sl +='<option '+selected+' value="'+v.code+'">'+v.fullname+'</option>';
                            });
                            sl += '</select></div>';
                            console.log(sl);
                            $("#c").after(sl);
                        }
                    });




                        $("#city").change(function () {
                            $("#a").remove();
                            var code = $(this).val();
                            $.ajax({
                                url:"?md=manage&cl=riders&at=getAreas",
                                type:"post",
                                dataType:"json",
                                data:{'code':code},
                                success:function (d) {
                                    console.log(d);
                                    var sl = '  <div class="form-group" style="width: 20%; " id="a"><label>服务区:</label><select class=" show-tick form-control"  name="_a" data-live-search="true"><option value="">请选择...</option>';
                                    $(d.data).each(function (k,v) {
                                        sl +='<option value="'+v.code+'">'+v.fullname+'</option>';
                                    });
                                    sl += '</select></div>';
                                    console.log(sl);
                                    $("#c").after(sl);
                                }
                            });
                        });


                    }
                });
            }


        });


    $("#province").change(function () {
        $("#c").remove();
        $("#a").remove();
        var code = $(this).val();
        if(!code)return;
        $.ajax({
            url:"?md=manage&cl=riders&at=getCitys",
            type:"post",
            dataType:"json",
            data:{'code':code},
            success:function (d) {
                var selected = '';
                if(d.status == 1){
                    var sl = '  <div class="form-group" style="width: 20%; " id="c"><label>服务市:</label><select class=" show-tick form-control" id="city" name="_c" data-live-search="true"><option value="">请选择...</option>';
                    $(d.data).each(function (k,v) {
                        sl +='<option '+selected+' value="'+v.code+'">'+v.fullname+'</option>';
                    });
                    sl += '</select></div>';
                    $("#p").after(sl);
                }


                $("#city").change(function () {
                    $("#a").remove();
                    var code = $(this).val();
                    $.ajax({
                        url:"?md=manage&cl=riders&at=getAreas",
                        type:"post",
                        dataType:"json",
                        data:{'code':code},
                        success:function (d) {
                            console.log(d);
                            var sl = '  <div class="form-group" style="width: 20%; " id="a"><label>服务区:</label><select class=" show-tick form-control"  name="_a" data-live-search="true"><option value="">请选择...</option>';
                            $(d.data).each(function (k,v) {
                                sl +='<option value="'+v.code+'">'+v.fullname+'</option>';
                            });
                            sl += '</select></div>';
                            console.log(sl);
                            $("#c").after(sl);
                        }
                    });
                });

            }
        });
    });

</script>
</body>
</html>
